﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PhysicsSimulator
{
    class DotValues : CGameObject
    {
        SpriteFont font;
        string _text;
        bool _is_x = true;
        public string Text
        {
            get { return _text; }
            set { _text = value; }
        }

        Vector2 _valuePositon;

        public Vector2 ValuePositon
        {
            get { return _valuePositon; }
            set { _valuePositon = value; }
        }

        public DotValues(SpriteBatch spriteBatch, string text, Vector2 position, bool is_x)
            : base(spriteBatch)
        {
            _text = text;
            _valuePositon = position;
            _is_x = is_x;
        }

        public override void Init(Microsoft.Xna.Framework.Content.ContentManager contentManager)
        {
            font = contentManager.Load<SpriteFont>("Fonts/ArialSmall");

            float messageWidth = font.MeasureString(_text).X;
            float messageHeigh = font.MeasureString(_text).Y;

            if (_is_x)
            {
                _valuePositon.X = _valuePositon.X - messageWidth/2;
                _valuePositon.Y = _valuePositon.Y + 5;
            }
            else
            {
                _valuePositon.X = _valuePositon.X - messageWidth - 5;
                _valuePositon.Y = _valuePositon.Y - messageHeigh / 2;
            }
            base.Init(contentManager);
        }

        public override void Draw(GameTimerEventArgs timer)
        {
            SpriteBatch.DrawString(font, _text, _valuePositon, Color.White);
            base.Draw(timer);
        }
    }
}
